using System;
using Microsoft.Xna.Framework;
using Core;

namespace SolarWinds.Transitions
{
    public class SlideTransition : Transition
    {
        public Direction Direction = Direction.LeftToRight;

        public SlideTransition(Game game)
            : base(game)
        {
        }

        protected override void Update(float progress)
        {
            // nonlinear mapping -> looks better
            progress = (float)Math.Sin(progress * 0.5 * Math.PI);

            int width = Game.Window.ClientBounds.Width;
            int height = Game.Window.ClientBounds.Height;

            Vector2 pos = Screen.Position;

            switch (Direction)
            {
                case Direction.LeftToRight: pos.X = -width; break;
                case Direction.RightToLeft: pos.X = width; break;
                case Direction.TopToBottom: pos.Y = -height; break;
                case Direction.BottomToTop: pos.Y = height; break;
                default: break;
            }

            switch (Mode)
            {
                case BlendModes.In: pos *= (1.0f - progress); break;
                case BlendModes.Out: pos *= progress; break;
                default: break;
            }

            Screen.Position = pos;
        }
    }
}